package model;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Vector;

import javax.swing.AbstractListModel;

public class DrawableListModel extends AbstractListModel {

	private Vector<IDrawable> theDrawables = null;
	
	public DrawableListModel() {
		super();
		theDrawables = new Vector<IDrawable>();
	}
	
	
	@Override
	public Object getElementAt(int arg0) {
		return theDrawables.elementAt(arg0);
	}

	@Override
	public int getSize() {
		return theDrawables.size();
	}
	
	public void addElement(IDrawable d) {
		theDrawables.add(d);
		this.fireIntervalAdded(this, theDrawables.size()-1, theDrawables.size()-1);
	}


	public void addAll(HashSet<IDrawable> theResultHashSet) {
		Iterator<IDrawable> iterator = theResultHashSet.iterator();
		while(iterator.hasNext()) {
			IDrawable next = iterator.next();
			this.addElement(next);
		}
		
	}

}
